package dataStructure.chapter06_树.part1二叉树.binarysearchtree1;

/**
 * @author https://gitee.com/W_Jun
 * @date 2022-03-07 17:58
 * @Description  二叉搜索树中的元素是自定义类的话需要指定比较规则,即实现Comparable接口
 */
public class Person implements Comparable<Person>{
    private int age;

    public Person(int age) {
        this.age = age;
    }

    public int getAge() {
        return age;
    }

    @Override
    public int compareTo(Person e) {
        return this.age - e.age;
    }

    @Override
    public String toString() {
        return "Person{" +
                "age=" + age +
                '}';
    }
}
